/////////////////////////page_rentalCar///////////////////
$(document).on("pageInit", "#page_rentalCar", function(e, pageId, $page) {
	setTimeout(function(){
    	$.showPreloader();
      },1)

                         my.givetitle('租车');
                        my.getlogintiaozhuan();
      	    	         key=my.get_key(my.getCookie('token'))
      	    	          var carListsort=''
      	    	          var loading = false;
                          var pageNow=1
                  //获取时间范围开始
                     var timeinfo={
      					u_userid:my.getCookie('id'),
      					}
      				timeinfo=my.cryptoASEencrypt(JSON.stringify(timeinfo),key)
      				$.ajax({
      					url:api.usercartimeinfo,
      					type: 'post',
      					async:true,
      					data:{
      						'api_value':timeinfo
      					},
      					error:function(){
      						    $.hidePreloader()
      						    $('.ball-pulse').hide()
      							$.toast("时间范围获取失败");
      						},
      					success:function(data){
      						$.hidePreloader()
      						if(data.match("err_code")!=null){
      							switch(JSON.parse(data).err_code)
      								{
                                    case 40003:
                                        my.tokenExpire()
                                        break;
                                    case 50390:
                                        $.alert('请确认是否泊车成功',function(){
                                            //window.location.href='/h5cargo/index/home.htm';
                                            $.router.load(homeUrl,true);
                                        });
                                        break;
                                    default:
                                        $.toast(JSON.parse(data).err_msg);
                                        // $.router.loadPage("home.html");
                                        $.router.load(homeUrl,true);
                                }
      						}else{
      							        data=JSON.parse(data)
      								    data=JSON.parse(my.cryptoASEdencrypt(data.data,key))
      								    console.log(data)
                                var now=new Date();
                                var afteryear  = new Date();
                                var months =  now.getMonth()+1;
                                var nowdateone =  now.getDate()+1;
                                afteryear.setFullYear(afteryear.getFullYear()+1);
                                var aftermonthsone =  afteryear.getMonth()+1;
                                var formatNumber = function (n) {
                                    return n < 10 ? "0" + n : n;
                                };

                                var minutesss = function (n) {
                                    if(n>=0 && n<=15){
                                        return '00';
                                    }
                                    if(n>15 && n<=30){
                                        return '30';
                                    }
                                    if(n>31 && n<=45){
                                        return '45';
                                    }
                                    if(n>45 && n<=60){
                                        return '45';
                                    }
                                };

                                         var cal_start_Y=data[0].cartime_start.substr(0,4)
                                         var cal_start_M=data[0].cartime_start.substr(5,2)
                                         var cal_start_D=data[0].cartime_start.substr(8,2)
                                         var cal_start_H=data[0].cartime_start.substr(11,2)
                                         var cal_start_S=data[0].cartime_start.substr(14,2)

                                         var cal_end_Y=data[0].cartime_end.substr(0,4)
                                         var cal_end_M=data[0].cartime_end.substr(5,2)
                                         var cal_end_D=data[0].cartime_end.substr(8,2)
                                         var cal_end_H=data[0].cartime_end.substr(11,2)
                                         var cal_end_S=data[0].cartime_end.substr(14,2)

                               $("#rang-time-start").datetimePickerCustom({
                                    customValue:cal_start_Y+"-"+cal_start_M+"-"+cal_start_D+" "+cal_start_H+":"+minutesss(cal_start_S)+":00",//指定控件中的当前时间日期,需要是示例所示标准格式
                                    /* customValue:now.getFullYear()+"-"+formatNumber(months)+"-"+formatNumber(now.getDate())+" "+formatNumber(now.getHours())+":"+minutesss(now.getMinutes())+":00",//指定控件中的当前时间日期,需要是示例所示标准格式*/
                                    customMinuteInterval:4,//指定分钟的间隔方式，此处整型指定分钟间隔的分母，如指定4，则为1/4，即分钟选择会变成00,15,30,45，该值不能为0
                                    hideMinute:false,//是否隐藏分钟,隐藏分钟则控件值为yyyy-MM-dd hh
                                    hideHour:false,//是否隐藏小时,隐藏小时则控件值为yyyy-MM-dd
                                    /*minDate:now.getFullYear()+"-"+formatNumber(months)+"-"+formatNumber(now.getDate())+" "+formatNumber(now.getHours())+":"+minutesss(now.getMinutes())+":00",//指定最小日期时间*/
                                   // minDate:cal_start_Y+"-"+cal_start_M+"-"+cal_start_D+" "+cal_start_H+":"+minutesss(cal_end_S)+":00",
                                    maxDate:afteryear.getFullYear()+"-"+formatNumber(aftermonthsone)+"-"+formatNumber(afteryear.getDate())+" "+formatNumber(afteryear.getHours())+":"+minutesss(afteryear.getMinutes())+":00",//指定最大日期时间
                                    hourLimit:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]//指定小时限制，只有数组中出现的小时才能被选择

                                });
                                $("#rang-time-end").datetimePickerCustom({
                                	customValue:cal_end_Y+"-"+cal_end_M+"-"+cal_end_D+" "+cal_end_H+":"+minutesss(cal_end_S)+":00",
                                   /* customValue:now.getFullYear()+"-"+months+"-"+nowdateone+" "+now.getHours()+":"+minutesss(now.getMinutes())+":00",//指定控件中的当前时间日期,需要是示例所示标准格式*/
                                    customMinuteInterval:4,//指定分钟的间隔方式，此处整型指定分钟间隔的分母，如指定4，则为1/4，即分钟选择会变成00,15,30,45，该值不能为0
                                    hideMinute:false,//是否隐藏分钟,隐藏分钟则控件值为yyyy-MM-dd hh
                                    hideHour:false,//是否隐藏小时,隐藏小时则控件值为yyyy-MM-dd
                                   // minDate:cal_end_Y+"-"+cal_end_M+"-"+cal_end_D+" "+cal_end_H+":"+minutesss(cal_end_S)+":00",
                                    maxDate:afteryear.getFullYear()+"-"+aftermonthsone+"-"+afteryear.getDate()+" "+afteryear.getHours()+":"+minutesss(afteryear.getMinutes())+":00",//指定最大日期时间
                                    hourLimit:[0,1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,21,22,23]//指定小时限制，只有数组中出现的小时才能被选择

                                });

      							 }
      					}
      				});
                    //获取时间范围结束
                     //选择服务地点start
                       $('.for-select-local').click(function(e){
      				        $.popup('.popup');
      			            $('[name=qrst]').triggerHandler('click')
      			        })
      			      function getStores(stores){
      			     	var list=stores
      			     	$('.get-car-lista span').click(function(){
		                   $('.get-car-lista span').removeClass('active')
		                   $(this).addClass('active')
		                   var name=$(this).attr('name')
		                   $('.get-car-listb span').remove()
		                   $('.get-car-listb').show()
		                   $('.get-car-listc,.get-car-listd,.get-car-other-box,.get-car-other-btn').hide()
		                   for( k in list){
		                  	  if(name.match(list[k].city_spell.substr(0,1))){
				                   var html="<span id='"+k+"'>"+list[k].city_name+"</span>"
				                   $('.get-car-listb').prepend(html)
		                       }
		                   }
		                   $('.get-car-listb span').click(function(){
		 	                   $('.get-car-listb span').removeClass('active')
		                       $(this).addClass('active')
		                       $('.get-car-listc span').remove()
		                       $('.get-car-listc').show()
		                       $('.get-car-listd span').remove()
		                       $('.get-car-listd').hide()
		                       var j=$(this).attr('id')
		                       for(k in list[j].ji){
				                     var html="<span id='"+j+"' name='"+k+"' >"+list[j].ji[k].airport_name+"</span>"
				                     $('.get-car-listc').prepend(html)
		                       }
		                       $('.get-car-listc span').click(function(){
		                   	                    //$('[name=cars_id]').val($(this).attr('name'))
		                   	                     $('.get-car-listc span').removeClass('active')
		                                         $(this).addClass('active')
		                                         $('.get-car-listd span').remove()
		                                         $('.get-car-listd').show()
		                                         var j=$(this).attr('id')
		                                         var w=$(this).attr('name')
		                                         for(k in list[j].ji[w].men){
				                                       var html="<span id='"+k+"'>"+list[j].ji[w].men[k].stores_name+"</span>"
				                                           $('.get-car-listd').prepend(html)
		                                            }
		                                          $('.get-car-listd span').click(function(){
		                                          	$('[name=park_place]').val($(this).attr('id'))
		                                          	$('[name=airport_id]').val($('.get-car-listc span.active').attr('id'))
		                                          	$('[name=city_id]').val($('.get-car-listb span.active').attr('id'))
                	                                $('.for-select-local-text').text($(this).text()).css('color','#0894ec')
                	                                $.closeModal('.popup')
                                                  })
	                          })
	                        })
                         })
      			     }
                     my.getStores(getStores)
                        //选择服务地点end
                        $('#rang-time').change(function(){
                        	var start_time=$('#rang-time-start').val()+":00";
                        	var end_time=$('#rang-time-end').val()+":00";
                        	var rang_time=start_time+" 到  "+end_time;
                        	$('#rang-time').val(rang_time)
                        })
                        $('.change-search').click(function(){
                       	    $('.carRental-main').show()
                         	$('.bar-header-secondary').hide()
                       	    $('.carlist').hide()
                        })
                        //提交点击效果
                        var seat
                        $('#carRental-submit').click(function(){
                        	$('#carRental-submit').addClass('active_btn')
                        	$.showPreloader()
                        	sessionStorage.car_place=$('[name=park_place]').val()
                        	sessionStorage.car_place_name=$('.for-select-local-text').text()
                        	sessionStorage.rangTimeStart=$('#rang-time-start').val()
                        	sessionStorage.rangTimeEnd=$('#rang-time-end').val()
	                        var info={
      					           user_id:my.getCookie('id'),
      					           car_place:$('[name=park_place]').val(),
      					           start_time:$('#rang-time-start').val(),
      					           end_time:$('#rang-time-end').val(),
      					           scb:$('[name=scb]').val(),
      					           seat:$('[name=seat]').val(),
      					           city:$('[name=city]').val(),
      					           page:1,
      					           rows:10,
      					           brandid:'',
      					           carsid:'',

      				        }
	                        console.log(info)
      				        info=my.cryptoASEencrypt(JSON.stringify(info),key)
      				        $.ajax({
      					       url:api.selectvehicle,
      					       type: 'post',
      					       async:true,
      					       data:{'api_value':info},
      					       error:function(){
      					       	   $.hidePreloader()
      					       	   $('#carRental-submit').removeClass('active_btn')
      					       	   $.toast("提交失败，请重试！");},
      					       success:function(data){
      					       	   $.hidePreloader()
      						     if(data.match("err_code")!=null){
      							    switch(JSON.parse(data).err_code)
      								{
      									case 40003:
      									   my.tokenExpire()
      									   break;
      									default:
      									   $.alert(JSON.parse(data).err_msg,function(){
      									   	$('#carRental-submit').removeClass('active_btn')
      									   })

      								}
      						     }else{
      						     	    $('#carRental-submit').removeClass('active_btn')
      							        data=JSON.parse(data)
      								    data=JSON.parse(my.cryptoASEdencrypt(data.data,key))
      								    carListsort=data.car_list
      								    carListsort.sort(function(x,y){return x.work_day_price-y.work_day_price})
      								    console.log(carListsort)
      								    sessionStorage.rentalCalCarList=JSON.stringify(carListsort)
      								    //sessionStorage.rentalCal_list=JSON.stringify(carListsort)
      								    $('.carRental-main').hide()
      				                    $('.bar-header-secondary').show()
      				                    $('.carlist').show()
      				                    $('.carR-car-list ul').empty()
      				                     if(carListsort.length<10){
      	    	                                 $.detachInfiniteScroll($('.infinite-scroll'));
                                                 $('.infinite-scroll-preloader').hide();
                                                 $('.infiniteOver').show()
      	    	                             }else{
      	    	                             	$.attachInfiniteScroll($('.infinite-scroll'));
                                                  $('.infinite-scroll-preloader').show();
                                                  $('.infiniteOver').hide()
      	    	                             }

      				                    for(i=0;i<carListsort.length;i++){

      				                    	var usercar_nickname=carListsort[i].usercar_nickname?carListsort[i].usercar_nickname.substr(0,2)+'***':'未填写'
      				                    	var speed_changing_box
      				                    	if(carListsort[i].speed_changing_box==1){
      				                    		speed_changing_box='手动'
      				                    	}else if(carListsort[i].speed_changing_box==2){
      				                    		speed_changing_box='自动'
      				                    	}
      				                    	switch(+carListsort[i].seat){
      				                    		case 1:
      				                    		seat="2座";
      				                    		break;
      				                    		case 2:
      				                    		seat="5座";
      				                    		break;
      				                    		case 3:
      				                    		seat="7座";
      				                    		break;
      				                    		case 4:
      				                    		seat="7座以上";
      				                    		break;
      				                    	}
      				                        var list='<li title="'+i+'" id="'+carListsort[i].usercar_id+'"><div><img style="height: 8rem;max-width: 100%;" src="'+config.url_car+carListsort[i].models_logo+'"></div><div>'
		                                          +carListsort[i].brand_chinese_name+'/'+carListsort[i].models_name+'</div><div><span>'
		                                          +carListsort[i].work_day_price+' 元起</span><span style="float: right;color: #fff;"></span><div class="clear"></div></div>'
		                                          +'<div class="qcxq">'+usercar_nickname+'/'+carListsort[i].usercar_color+'/'+speed_changing_box+'/行李箱'
                                                  +carListsort[i].trunk_capacity+'L/'+seat+'</div></li>'
      				                        $('.carR-car-list ul').append(list)

      				                    }
//    				                     $('.carR-car-list ul li').click(function(){
//    				                    	var id=$(this).attr('title')
//    				                    	sessionStorage.rentalCalDetails=JSON.stringify(carListsort[id])
//    				                    	sessionStorage.carDetails_carid=carListsort[id].usercar_id
//    				                    	//$.router.loadPage("carDetails.html");
//                                           $.router.load(carDetailsUrl,true);
//    				                     })

      							}
      					    }
      			         })
      			        })
                        //车辆列表点击事件
                        $('.carR-car-list ul').on('click','li',function(){
                        	var id=$(this).attr('title')
                        	var carList=JSON.parse(sessionStorage.rentalCalCarList)
                        	console.log($(this).attr('id'))
                        	console.log(carList[id].usercar_id)
                        	sessionStorage.rentalCalDetails=JSON.stringify(carList[id])
      				        sessionStorage.carDetails_carid=carList[id].usercar_id
                            $.router.load(carDetailsUrl,true);
                        })
                        //排序开始
                         $('.RCR-px').click(function(){
                         	if($('.RCR-px span:first-child').text()=="价格从低到高"){
                         		$('.RCR-px span:first-child').text("价格从高到低")

                         	}else if($('.RCR-px span:first-child').text()=="价格从高到低"){
                         		$('.RCR-px span:first-child').text("价格从低到高")

                         	}
                         	var carListsort=JSON.parse(sessionStorage.rentalCalCarList)
                         	 carListsort.reverse()
                         	 sessionStorage.rentalCalCarList=JSON.stringify(carListsort)
                         	 $('.carR-car-list ul').empty()
                         	 for(i=0;i<carListsort.length;i++){
                         	 	            var usercar_nickname=carListsort[i].usercar_nickname.substr(0,2)+'***'
      				                    	var speed_changing_box
      				                    	if(carListsort[i].speed_changing_box==1){
      				                    		speed_changing_box='手动'
      				                    	}else if(carListsort[i].speed_changing_box==2){
      				                    		speed_changing_box='自动'
      				                    	}
      				                    	switch(+carListsort[i].seat){
      				                    		case 1:
      				                    		seat="2座";
      				                    		break;
      				                    		case 2:
      				                    		seat="5座";
      				                    		break;
      				                    		case 3:
      				                    		seat="7座";
      				                    		break;
      				                    		case 4:
      				                    		seat="7座以上";
      				                    		break;
      				                    	}
      				                         var list='<li title="'+i+'" id="'+carListsort[i].usercar_id+'"><div><img style="height:8rem;max-width: 100%;" src="'+config.url_car+carListsort[i].models_logo+'"></div><div>'
		                                          +carListsort[i].brand_chinese_name+'/'+carListsort[i].models_name+'</div><div><span>'
		                                          +carListsort[i].work_day_price+' 元起</span><span style="float: right;color: #fff;"></span><div class="clear"></div></div>'
		                                          +'<div class="qcxq">'+usercar_nickname+'/'+carListsort[i].usercar_color+'/'+speed_changing_box+'/行李箱'
                                                  +carListsort[i].trunk_capacity+'L/'+seat+'</div></li>'
      				                        $('.carR-car-list ul').append(list)

      				                    }
      				                     $('.carR-car-list ul li').click(function(){
      				                    	var id=$(this).attr('title')
      				                    	sessionStorage.rentalCalDetails=JSON.stringify(carListsort[id])
      				                    	sessionStorage.carDetails_carid=carListsort[id].usercar_id
      				                    	//$.router.loadPage("carDetails.html");
                                             $.router.load(carDetailsUrl,true);
      				        })
                         })
                        //排序结束
                        //更多选项
                        $('#show-morefree').click(function(){
      				    $('.RC-more').toggle()
      				     if($(this).find('img').attr('src')=='/h5car/img/icon/icon_down.png'){
      				     	$(this).find('img').attr('src','/h5car/img/icon/icon_up.png')
      				     }else{
      				     	$(this).find('img').attr('src','/h5car/img/icon/icon_down.png')
      				     }
      			        })
                        $('.RC-more li').eq(0).click(function(){
                        	$('.RC-more-up-b').show()
                        	$('.RC-more-up').not('.RC-more-up-b').hide()
                        })
                        $('.RC-more-up-b span').click(function(){
                        	$('.RC-more li').eq(0).find('span').eq(1).text($(this).text()).css('color','#0894ec')
                        	$('[name=scb]').val($(this).attr('title'))
                        	$('.RC-more-up').hide()
                        })
                        $('.RC-more li').eq(1).click(function(){
                        	$('.RC-more-up-c').show()
                        	$('.RC-more-up').not('.RC-more-up-c').hide()
                        })
                        $('.RC-more-up-c span').click(function(){
                        	$('.RC-more li').eq(1).find('span').eq(1).text($(this).text()).css('color','#0894ec')
                        	$('[name=seat]').val($(this).attr('title'))
                        	$('.RC-more-up').hide()
                        })
                        $('.RC-more li').eq(2).click(function(){
                        	$('.RC-more-up-d').show()
                        	$('.RC-more-up').not('.RC-more-up-d').hide()
                        })
                        $('.RC-more-up-d span').click(function(){
                        	$('.RC-more li').eq(2).find('span').eq(1).text($(this).text()).css('color','#0894ec')
                        	$('[name=city]').val($(this).attr('title'))
                        	$('.RC-more-up').hide()
                        })
                        //选择车型

                        //下拉刷新start
      		             $(document).on('refresh', '.pull-to-refresh-content-rentalCarList',function() {
	                        var info={
      					           user_id:my.getCookie('id'),
      					           car_place:$('[name=park_place]').val(),
      					           start_time:$('#rang-time-start').val(),
      					           end_time:$('#rang-time-end').val(),
      					           scb:$('[name=scb]').val(),
      					           seat:$('[name=seat]').val(),
      					           city:$('[name=city]').val(),
      					           page:1,
      					           rows:10,
      					           brandid:'',
      					           carsid:'',

      				        }
	                        console.log(info)
      				        info=my.cryptoASEencrypt(JSON.stringify(info),key)
      				        $.ajax({
      					       url:api.selectvehicle,
      					       type: 'post',
      					       async:true,
      					       data:{'api_value':info},
      					       error:function(){
      					       	   $.pullToRefreshDone('.pull-to-refresh-content');
      					       	   $.toast("提交失败，请重试！");},
      					       success:function(data){
      						     if(data.match("err_code")!=null){
      							    switch(JSON.parse(data).err_code)
      								{
      									case 40003:
      									   $.pullToRefreshDone('.pull-to-refresh-content');
      									   my.tokenExpire()
      									   break;
      									default:
      									   $.pullToRefreshDone('.pull-to-refresh-content');
      									   $.toast(JSON.parse(data).err_msg);
      								}
      						     }else{
      						     	    $.pullToRefreshDone('.pull-to-refresh-content');
      							        data=JSON.parse(data)
      								    data=JSON.parse(my.cryptoASEdencrypt(data.data,key))
      								    console.log(data)
                                         if(carListsort.length<10){
      	    	                                 $.detachInfiniteScroll($('.infinite-scroll'));
                                                 $('.infinite-scroll-preloader').hide();
                                                 $('.infiniteOver').show()
      	    	                             }else{
      	    	                             	$.attachInfiniteScroll($('.infinite-scroll'));
                                                  $('.infinite-scroll-preloader').show();
                                                  $('.infiniteOver').hide()
      	    	                        }
      								    carListsort=data.car_list
      								    carListsort.sort(function(x,y){return x.work_day_price-y.work_day_price})
      								    //sessionStorage.rentalCal_list=JSON.stringify(carListsort)
      								    $('.carRental-main').hide()
      				                    $('.bar-header-secondary').show()
      				                    $('.carlist').show()
      				                    $.hideIndicator()
      				                    $('.carR-car-list ul').empty()
      				                    for(i=0;i<carListsort.length;i++){
      				                    	var usercar_nickname=carListsort[i].usercar_nickname.substr(0,2)+'***'
      				                    	var speed_changing_box
      				                    	if(carListsort[i].speed_changing_box==1){
      				                    		speed_changing_box='手动'
      				                    	}else if(carListsort[i].speed_changing_box==2){
      				                    		speed_changing_box='自动'
      				                    	}
      				                    	switch(+carListsort[i].seat){
      				                    		case 1:
      				                    		seat="2座";
      				                    		break;
      				                    		case 2:
      				                    		seat="5座";
      				                    		break;
      				                    		case 3:
      				                    		seat="7座";
      				                    		break;
      				                    		case 4:
      				                    		seat="7座以上";
      				                    		break;
      				                    	}
      				                        var list='<li title="'+i+'" id="'+carListsort[i].usercar_id+'"><div><img style="height:8rem;max-width: 100%;" src="'+config.url_car+carListsort[i].models_logo+'"></div><div>'
		                                          +carListsort[i].brand_chinese_name+'/'+carListsort[i].models_name+'</div><div><span>'
		                                          +carListsort[i].work_day_price+' 元起</span><span style="float: right;color: #fff;"></span><div class="clear"></div></div>'
		                                          +'<div class="qcxq">'+usercar_nickname+'/'+carListsort[i].usercar_color+'/'+speed_changing_box+'/行李箱'
                                                  +carListsort[i].trunk_capacity+'L/'+seat+'</div></li>'
      				                        $('.carR-car-list ul').append(list)

      				                    }
      				                     $('.carR-car-list ul li').click(function(){
      				                    	var id=$(this).attr('title')
      				                    	sessionStorage.rentalCalDetails=JSON.stringify(carListsort[id])
      				                    	sessionStorage.carDetails_carid=carListsort[id].usercar_id
      				                    	//$.router.loadPage("carDetails.html");
                                             $.router.load(carDetailsUrl,true);
      				                     })

      							}
      					    }
      			         })
                });//下拉刷新end
                         //无限加载
      	    	         $(document).on("infinite", ".infinite-scroll-rentalCarList", function() {
                    //   如果正在加载，则退出
                    if (loading) return;
                    pageNow=Math.ceil($('.carR-car-list ul li').length/10+0.01)
                    console.log('pageNow:'+pageNow)
                    loading = true;
                    setTimeout(function() {
                    loading = false;
                    var info={
      					           user_id:my.getCookie('id'),
      					           car_place:$('[name=park_place]').val(),
      					           start_time:$('#rang-time-start').val()+":00:00",
      					           end_time:$('#rang-time-end').val()+":00:00",
      					           scb:$('[name=scb]').val(),
      					           seat:$('[name=seat]').val(),
      					           city:$('[name=city]').val(),
      					           page:pageNow,
      					           rows:10,
      					           brandid:'',
      					           carsid:'',

      				        }
      				        info=my.cryptoASEencrypt(JSON.stringify(info),key)
      				        $.ajax({
      					       url:api.selectvehicle,
      					       type: 'post',
      					       async:true,
      					       data:{'api_value':info},
      					       error:function(){
      					       	   $.hidePreloader()
      					       	   $('#carRental-submit').removeClass('active_btn')
      					       	   $.toast("提交失败，请重试！");},
      					       success:function(data){
      					       	   $.hidePreloader()
      						     if(data.match("err_code")!=null){

      							    switch(JSON.parse(data).err_code)
      								{
      									case 40003:
      									   my.tokenExpire()
      									   break;
      									default:
      									   $.alert(JSON.parse(data).err_msg,function(){
      									   	  $.detachInfiniteScroll($('.infinite-scroll'));
                                               $('.infinite-scroll-preloader').hide();
                                               $('.infiniteOver').show()
      									   })
      								}
      						     }else{
      							        data=JSON.parse(data)
      								    data=JSON.parse(my.cryptoASEdencrypt(data.data,key))

      								    carListsort=carListsort.concat(data.car_list)
      								   // carListsort=carListsort
      								    carListsort.sort(function(x,y){return x.work_day_price-y.work_day_price})

      	    	   	                       if(carListsort.length!=0){
      	    	   		                       if(pageNow==1){
      	    	   		                               $('.carR-car-list ul').empty()
      	    	   		                          }
      	    	   		                   for(i=0;i<carListsort.length;i++){
      				                    	  var usercar_nickname=carListsort[i].usercar_nickname.substr(0,2)+'***'
      				                    	  var speed_changing_box
      				                    	  if(carListsort[i].speed_changing_box==1){
      				                    		speed_changing_box='手动'
      				                    	    }else if(carListsort[i].speed_changing_box==2){
      				                    		speed_changing_box='自动'
      				                    	    }
      				                    	    switch(+carListsort[i].seat){
      				                    		case 1:
      				                    		seat="2座";
      				                    		break;
      				                    		case 2:
      				                    		seat="5座";
      				                    		break;
      				                    		case 3:
      				                    		seat="7座";
      				                    		break;
      				                    		case 4:
      				                    		seat="7座以上";
      				                    		break;
      				                    	}
      				                            var list='<li title="'+i+'" id="'+carListsort[i].usercar_id+'"><div><img style="height: 8rem;max-width: 100%;" src="'+config.url_car+carListsort[i].models_logo+'"></div><div>'
		                                          +carListsort[i].brand_chinese_name+'/'+carListsort[i].models_name+'</div><div><span>'
		                                          +carListsort[i].work_day_price+' 元起</span><span style="float: right;color: #fff;"></span><div class="clear"></div></div>'
		                                          +'<div class="qcxq">'+usercar_nickname+'/'+carListsort[i].usercar_color+'/'+speed_changing_box+'/行李箱'
                                                  +carListsort[i].trunk_capacity+'L/'+seat+'</div></li>'
      				                            $('.carR-car-list ul').append(list)

      				                       }
      	    	                           if(carListsort.length<10){
      	    	                                 $.detachInfiniteScroll($('.infinite-scroll'));
                                                 $('.infinite-scroll-preloader').hide();
                                                 $('.infiniteOver').show()
      	    	                             }
      	    	                           $('.carR-car-list ul li').click(function(){
      				                    	    var id=$(this).attr('title')
      				                    	    sessionStorage.rentalCalDetails=JSON.stringify(carListsort[id])
      				                    	    sessionStorage.carDetails_carid=carListsort[id].usercar_id
      				                        })
      	    	                           }else{
      	    	     	                       $.detachInfiniteScroll($('.infinite-scroll'));
                                               $('.infinite-scroll-preloader').hide();
                                               $('.infiniteOver').show()
      	    	                            }

      							}
      					    }
      			         })
      			    }, 2000);

               });
});

$(document).on("pageInit", "#page_noLoginRentalCar", function(e, pageId, $page) {
    my.getlogintiaozhuan();
    $(".nologinrentalrcar").on("click",function(){
        if(my.getCookie('token') && my.getCookie('id')){
            $.router.load(config.domain+'/h5cargo/index/rentalcar.htm#page_rentalCar',true);
        }else {
            $.router.load(config.domain + loginUrl + '?return_url=/h5cargo/index/rentalcar.htm#page_rentalCar', true);
        }
    });
       var mySwiper = new Swiper('.swiper-container',{
                                                       pagination : '.swiper-pagination',
                                                       autoplay : 4000,
                 })
});